<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <title>主页</title>
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}">
    <script th:src="@{/static/jquery-2.1.4.js}" type="text/javascript" charset="utf-8"></script>
    <script th:src="@{/static/layui/layui.js}" type="text/javascript" charset="utf-8"></script>
    <script th:src="@{/static/mylayer.js}" type="text/javascript" charset="utf-8"></script>
    <script th:src="@{/static/kindeditor/kindeditor.js}" type="text/javascript" charset="utf-8"></script>
    <style>
        .avatar-img {
            width: 50px; /* 设置头像图片的宽度 */
            height: 50px; /* 设置头像图片的高度，可以根据需要调整 */
            border-radius: 50%; /* 使图片呈现圆形 */
            margin-right: 10px; /* 设置头像图片与用户名之间的间距，可以根据需要调整 */
        }
    </style>
</head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo layui-hide-xs">
                <img src="/static/pic/xx-logo.png" style="width: 200px ;height: 50px" alt="">
            </div>
            <ul class="layui-nav layui-layout-left">   </ul>
            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item">
                    <a href="javascript:;">
                        <img class="avatar-img" th:src="${session.admin.image}" />
                        <span th:text="${session.admin.name}"></span>
                    </a>
                    <dl class="layui-nav-child">
                        <dd>
                            <a href="javascript:;"
                               data-url="page/admininfo" class="site-demo-active">基本资料</a>
                        </dd>
                        <dd>
                            <a href="javascript:openInfo()">修改资料</a>
                        </dd>
                        <dd>
                            <a href="javascript:openPass()">修改密码</a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:logout()">注销</a>
                </li>
            </ul>
        </div>
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" >
                    <li class="layui-nav-item layui-nav-itemed">
                        <a href="javascript:;">信息维护</a>
                        <dl class="layui-nav-child">
                            <dd>
                                <a href="javascript:;"
                                   data-url="/page/carousel/list"
                                   class="site-demo-active">轮播图管理</a>
                            </dd>
                            <dd>
                                <a href="javascript:;"
                                   data-url="/page/product/list"
                                   class="site-demo-active">商品管理</a>
                            </dd>
                            <dd>
                                <a href="javascript:;"
                                   data-url="/page/category/list"
                                   class="site-demo-active">分类管理</a>
                            </dd>
                            <dd>
                                <a href="javascript:;"
                                   data-url="/page/user/list"
                                   class="site-demo-active">用户管理</a>
                            </dd>
                            <dd>
                                <a href="javascript:;"
                                   data-url="/page/order/list"
                                   class="site-demo-active">订单管理</a>
                            </dd>
<!--                            <dd>-->
<!--                                <a href="javascript:;"-->
<!--                                   data-url="/page/shipping/list"-->
<!--                                   class="site-demo-active">地址管理</a>-->
<!--                            </dd>-->
                            <dd>
                                <a href="javascript:;"
                                   data-url="/page/echarts"
                                   class="site-demo-active">统计图表</a>
                            </dd>

                        </dl>
                    </li>
                    <li class="layui-nav-item">
                        <a href="javascript:;">管理员信息</a>
                        <dl class="layui-nav-child">
                            <th:block th:if="${session.admin.role == 0}">
                                <dd>
                                    <a href="javascript:;"
                                       class="site-demo-active"
                                       data-url="/page/admin/list">
                                        管理员管理</a>
                                </dd>
                            </th:block>

                            <dd>
                                <a href="javascript:;" class="site-demo-active"
                                   data-url="/page/admininfo">个人信息</a>
                            </dd>
                        </dl>
                    </li>
                </ul>
            </div>
        </div>
        <div class="layui-body"><!-- 内容主体区域 -->
            <iframe name="rightframe" width="100%" height="100%" src="/page/echarts"></iframe>
        </div>
        <%--    <div class="layui-footer">© JAVA - 底部固定区域</div>--%>
    </div>
    <script type="text/javascript">
        var $ = layui.jquery;
        var layer = layui.layer;
        var element = layui.element;
        $('.site-demo-active').click(function() {
            window.open($(this).data('url'), "rightframe");
        });
        element.render();// element.init();
        function openURL(url){
            window.open(url, "rightframe");
        }
        function openInfo() {
            layer.open({
                title: '修改个人信息',
                type: 2,
                area: ['35%', '90%'],// 宽高
                content: '/page/admininfo/updateinfo',
            });
        }
        function openPass() {
            layer.open({
                title: '修改密码',
                type: 2,
                area: ['35%', '60%'],// 宽高
                content: '/page/admininfo/updatepassword',
            });
        }
        function logout() {
            layer.confirm(
                '您确认要退出么',
                {icon:3},
                function() {
                    $.post(
                        '/admin/logout',
                        function (result) {
                            if (result.code == 0) {
                                mylayer.okUrl(result.msg, '/page/login');
                            }
                        },
                        'json'
                    );
                    // location.href = '/admin?method=logout'
                }
            );
        }
    </script>
</body>
</html>